package com.mutouren.web.demo;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.mutouren.common.web.BootStrapPage;
import com.mutouren.common.web.BootStrapPage.HtmlPage;

@Controller
@RequestMapping(value="/demo")
public class OneAction {

	@RequestMapping(value="/func1.action")
	public String func1(HttpServletRequest request) {
		request.setAttribute("hello_url", request.getRequestURI());
		return "modules/demo/one";
	}
	
	@RequestMapping(value="/func2.action")
	public String func2(HttpServletRequest request) {
		request.setAttribute("hello_url", request.getRequestURI());
		return "modules/demo/one";
	}	
	
	@RequestMapping(value="/func3.action")
	public String func3(HttpServletRequest request) {
		request.setAttribute("hello_url", request.getRequestURI());
		return "modules/demo/one";
	}	
	@RequestMapping(value="/func4.action")
	public String func4(
			@RequestParam(value="total", required=false, defaultValue="0") int total,
			@RequestParam(value="pageSize", required=false, defaultValue="10") int pageSize,
			@RequestParam(value="curIndex", required=false, defaultValue="1") int curIndex,
			HttpServletRequest request) {
		
		HtmlPage mtrPage = BootStrapPage.buildHtmlPage(total, pageSize, curIndex);
		request.setAttribute("mtrPage", mtrPage);
		return "modules/demo/page";
	}	
}
